package com.inossem.warehousestorage_inossem.adapter.allocation;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.inossem.warehousestorage_inossem.R;

import java.util.List;

/**
 * TODO
 *
 * @author 詹建宇
 * @time on 2018/4/4 15:41
 * @email jianyu.zhan@inossem.com
 */
public class AllocationInPackageAdapter extends BaseAdapter {

    private Context context;
    //该序列号列表下 不重复的 打包码列表
    private List<String> codes;

    public AllocationInPackageAdapter(Context context, List<String> codes) {
        this.context = context;
        this.codes = codes;
    }

    @Override
    public int getCount() {
        return codes.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.cy_view_in_storage_allocation_mat_sn_item, null);
            holder = new ViewHolder();
            holder.icon = (ImageView) view.findViewById(R.id.icon);
            holder.type = (TextView) view.findViewById(R.id.type);
            holder.codeTv = (TextView) view.findViewById(R.id.codeTv);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.icon.setImageResource(R.drawable.ico_package_code);
        holder.type.setText("打包码");
        holder.codeTv.setText(String.valueOf(codes.get(i)));
        return view;
    }

    private class ViewHolder {
        private ImageView icon;
        private TextView type;
        private TextView codeTv;
    }
}
